<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title></title>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all"/>
</head>
<body layadmin-themealias="default">
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                {if $uid>0}
                <div class="layui-tab layui-tab-brief">
                    <ul class="layui-tab-title layui_tab_title">
                        <li class=""><a href="{:url('user/backpack',array('uid'=>$uid))}">背包情况</a></li>
                        <li class="layui-this"><a href="{:url('user/ticket',array('uid'=>$uid))}">发放观赛券</a></li>
                        <li class=""><a href="{:url('user/give_ticket_log',array('uid'=>$uid))}">观赛券发放记录</a></li>
                        <li class=""><a href="{:url('user/used_ticket_log',array('uid'=>$uid))}">观赛券用券记录</a></li>
                        <li class=""><a href="{:url('order/user_order',array('uid'=>$uid))}">充值记录</a></li>
                        <li class=""><a href="{:url('gift/user_send',array('uid'=>$uid))}">送礼记录</a></li>
                        <li class=""><a href="{:url('charge/manual',array('uid'=>$uid))}">人工上分</a></li>
                        <li class=""><a href="{:url('user/login_log',array('uid'=>$uid))}">登录日志</a></li>
                    </ul>
                </div>
                {/if}

                <div class="layui-card-body" pad15="">
                    <div class="layui-form" wid100="" lay-filter="">
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户ID</label>
                            <div class="layui-input-inline">
                                <input type="text" name="id" value="{$uid|default=''}" class="layui-input" lay-verify="required|number" placeholder="请输入用户ID" <?php if(!empty($uid)){ echo 'readonly="true" disabled="true"';} ?> />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">新增观赛券数量</label>
                            <div class="layui-input-inline">
                                <input type="text" name="quantity" value="1" class="layui-input" lay-verify="required|number" placeholder="请输入整数" onkeyup="input_num(this)"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block text-center">
                                <button class="layui-btn" lay-submit="" lay-filter="manual-save">
                                    确认保存
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: "/layuiadmin/"
        , version: "{:config('other.ui_version')}"
    }).extend({
        index: "lib/index", //主入口模块
    }).use(["index", "form", "admin"], function () {
        var $ = layui.$,
            form = layui.form,
            admin = layui.admin;
        var index = parent.layer.getFrameIndex(window.name);

        form.on("submit(manual-save)", function (obj) {
            //提交
            admin.req({
                url: "/admin/user/ticket",
                data: obj.field,
                success: function (res) {
                    if (res.code == 0) {
                        layer.msg(res.msg, {icon: 1}, function () {
                            window.location.reload();
                        });
                    }
                },
            });
            return false;
        });
    });

    function input_num(obj){
        obj.value = obj.value.replace(/[^\d.]/g,"");
        obj.value = obj.value.replace(/^\./g,"");
        obj.value = obj.value.replace(/\.{2,}/g,".");
        obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');

        if(obj.value.indexOf(".")> 0  && obj.value.indexOf("0")>2){
            obj.value= parseFloat(obj.value);
        }
        if(obj.value.indexOf(".")> 0  && obj.value.lastIndexOf("0")>2){
            obj.value= parseFloat(obj.value);
        }
        if (obj.value.indexOf(".") <= 0 && obj.value != "") {
            obj.value = parseFloat(obj.value);
        }
    }
</script>
</body>
</html>
